const dataSetApi = require('./data-set-api')
const dataSourceApi = require('./datasource-api')
const dbApi = require('./db-api')
const userMockApi = require('./user-mock-api')


function _install(a, app) {
    const baseRouterUrl = a.baseRouterUrl
    a = a || {}
    Object.keys(a).forEach((r) => {
        if (typeof a[r] === 'function') {
            app.post(baseRouterUrl + r, a[r])
        }
    })
}

exports.installApp = function (app) {
    _install(dataSetApi, app)
    _install(dataSourceApi, app)
    _install(dbApi, app)
    _install(userMockApi, app)
}